#include "show.h"


unsigned char code str[8] = {0x02,0x05,0x02,0x00,0x00,0x00,0x00,0x00};//摄氏度左上角的句号
unsigned char code AlarmOnStr[] = "ON ";//AlarmFlag标志为1显示ON
unsigned char code AlarmOffStr[] = "OFF";//AlarmFlag标志为1显示OFF

/***********************************
函数名：TimeShow
功  能：时钟显示
参  数：无
返回值：无
*************************************/	
void TimeShow(void)
{
	unsigned char date_buf[16];//年月日数据缓冲区
	unsigned char time_buf[9];//时间数据缓冲区
	unsigned char temp_buf[8];//温度数据缓冲区

	if(0 == mode)//正常模式显示
	{
		sec = DS1302_TIME[0];	//将从DS1302读出的秒分时日月年星期几传给变量
		min = DS1302_TIME[1];
		hour = DS1302_TIME[2];
		day = DS1302_TIME[3];
		month = DS1302_TIME[4];
		week = DS1302_TIME[5];
		year = DS1302_TIME[6];

		TimeMenu(date_buf,time_buf);//将变量传入菜单中转换，并存在数组中，利用LCD1602进行显示			
		TempertureMenu(temp_buf);
		LCDShowStr(0,0,date_buf);
		LCDShowStr(0,1,time_buf);
		LCDShowStr(9,1,temp_buf);
		LCDSetChar(13,1,0,str);//摄氏度符号显示，自定义字符加C显示
		LCDShowStr(14,1,"C");
	}
	else if(1 == mode)//时钟设置模式显示
	{
		TimeMenu(date_buf,time_buf);			
		TempertureMenu(temp_buf);
		LCDShowStr(0,0,date_buf);
		LCDShowStr(0,1,time_buf);
		LCDShowStr(9,1,"OK/ESC");			
	}
	else if(2 == mode)//闹钟设置模式显示
	{	
		LCDShowStr(0,0,"Alarm:");
		AlarmMenu(time_buf);	
		LCDShowStr(0,1,time_buf);
		if(AlarmFlag)
			LCDShowStr(7,0,AlarmOnStr);	
		else
			LCDShowStr(7,0,AlarmOffStr);		
	}			
}

void CursorFlashing()
{
	if(1 == mode)//模拟光标闪烁
	{
		if (TimeChoice < 3)
			LCDShowStr(6 - TimeChoice * 3,1,"  ");
		else if(TimeChoice == 3)
			LCDShowStr(14,0," ");
		else if(TimeChoice == 4)
			LCDShowStr(0,0,"    ");
		else if(TimeChoice == 5)
			LCDShowStr(5,0,"  ");
		else if(TimeChoice == 6)
			LCDShowStr(8,0,"  ");		
	}
	else if(2 == mode)//模拟光标闪烁
		{
			if(TimeChoice < 2)
				LCDShowStr(3 - TimeChoice * 3,1,"  ");
			else if(TimeChoice == 2)
				LCDShowStr(7,0,"   ");
			else if(TimeChoice == 3)
				LCDShowStr(3,1,"  ");		
		}
}
